<div class="crumb-wrap">
    <div class="crumb-list"> <i class="icon-font"></i>
        <a href="<?=site_url()?>">首页</a>
        <span class="crumb-step">&gt;</span>
        <a class="crumb-name" href="<?=site_url('users/index')?>">用户管理</a>
        <span class="crumb-step">&gt;</span>
        <span>新增用户</span>
    </div>
</div>
<div class="result-wrap">
    <div class="result-content">
        <form action="<?=site_url('users/create')?>" method="post" id="myform" name="myform" enctype="multipart/form-data">
            <table class="insert-tab" width="100%">
                <tbody>
                    <tr>
                        <th width="120"> <i class="require-red">*</i>
                            用户组：
                        </th>
                        <td>
                            <select name="status" id="catid" class="required" onchange="is_group(this.value)">
                                <option value="3">普通用户</option>
                                <option value="2">管理员</option>
                            </select>
                        </td>
                    </tr>
                    <tr id="group" style="display: none">
                        <th width="120"> <i class="require-red">*</i>
                            用户级别：
                        </th>
                        <td>
                            <select name="group_id" id="catid" class="required">
                                <?php foreach($groups as $k => $v):?>
                                    <option value="<?=$v['id']?>" title="优惠折扣：<?=$v['discount']?>折 ; <?=$v['remark']?>"><?=$v['title']?></option>
                                <?php endforeach;?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>登录帐号</th>
                        <td>
                            <input class="common-text required" id="title" name="user_name" size="50" value="" type="text"></td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>登录密码</th>
                        <td>
                            <input class="common-text required" id="title" name="pass" size="50" value="" type="password"></td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>确认密码</th>
                        <td>
                            <input class="common-text required" id="title" name="password_1" size="50" value="" type="password"></td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>真实姓名</th>
                        <td>
                            <input class="common-text required" id="title" name="name" size="50" value="" type="text"></td>
                    </tr>

                    <tr>
                        <th><i class="require-red">*</i>联系电话</th>
                        <td>
                            <input class="common-text required" id="title" name="phone" size="50" value="" type="text"></td>
                    </tr>

                    <tr>
                        <th><i class="require-red">*</i>联系邮箱</th>
                        <td>
                            <input class="common-text required" id="title" name="email" size="50" value="" type="text"></td>
                    </tr>

                    <tr>
                        <th>QQ：</th>
                        <td>
                            <input class="common-text" name="qq" size="50" value="" type="text"></td>
                    </tr>
                    <tr>
                        <th>weixin：</th>
                        <td>
                            <input class="common-text" name="weixin" size="50" value="" type="text"></td>
                    </tr>
                    <tr>
                        <th>地址：</th>
                        <td>
                            <input class="common-text" name="address" size="50" value="" type="text"></td>
                    </tr>
                    <tr>
                        <th>单位：</th>
                        <td>
                            <input class="common-text" name="company" size="50" value="" type="text"></td>
                    </tr>


                    <tr>
                        <th></th>
                        <td>
                            <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                            <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button"></td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        var val = $("select[name=status]").val();
        is_group(val);
    });


    function is_group(val){
        if(val == 3){
            $("#group").attr('style','');
        }else{
            $("#group").attr('style','display: none');
        }
    }

    $('#myform').submit(function() {
        var index = layer.load(2);
        $(this).ajaxSubmit(function(data){
            layer.close(index);
            if(data == 1){
                layer.alert("操作成功！",{
                    icon:1,
                },function(){
                    location.href='<?=site_url("users/index")?>';
                });
            }else{
                layer.alert(data,{
                    icon:2,
                });
            }
        })
        return false;
    })

</script>